<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDeviceLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('device_logs', function (Blueprint $table) {
            $table->unsignedBigInteger('id')->primary();
            $table->string('content')->nullable()->default('')->comment('日志');
            $table->unsignedBigInteger('user_id')->default(0)->comment('创建用户ID')->index('user');
            $table->unsignedBigInteger('device_id')->default(0)->comment('设备ID')->index('device');
            $table->string('level')->nullable()->default('default')->comment('日志等级');
            $table->timestamps();
            $table->softDeletes();
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';
            $table->engine = 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('device_logs');
    }
}
